package me.notfirecodes.serverpatcher.cmds;

import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;

public class MaxHealthCMD implements CommandExecutor {
    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args){
        if(sender instanceof Player){
            Player player = (Player) sender;
            if(player.hasPermission("serverpatcher.maxhealth")){
                player.setMaxHealth(20);
                player.setHealth(20);
                player.sendMessage(ChatColor.GREEN + "Your health was set to the maximum!");
            }
            else{
                player.sendMessage(ChatColor.RED + "You do not have permission to run this command.");
            }
        }
        else{
            System.out.println(ChatColor.RED + "You cannot run this command with console!");
        }
    return true;
    }
}
